//
//  HuangwwAuthID.h
//  Huangww
//
//  Created by lee on 2019/4/15.
//  Copyright © 2019 Huangww. All rights reserved.
//

#import <LocalAuthentication/LocalAuthentication.h>

NS_ASSUME_NONNULL_BEGIN


/**
 *  TouchID/FaceID 状态
 */
typedef NS_ENUM(NSUInteger, HuangwwAuthIDState){
    
    /**
     *  当前设备不支持TouchID/FaceID
     */
    HuangwwAuthIDStateNotSupport = 0,
    /**
     *  TouchID/FaceID 验证成功
     */
    HuangwwAuthIDStateSuccess = 1,
    
    /**
     *  TouchID/FaceID 验证失败
     */
    HuangwwAuthIDStateFail = 2,
    /**
     *  TouchID/FaceID 被用户手动取消
     */
    HuangwwAuthIDStateUserCancel = 3,
    /**
     *  用户不使用TouchID/FaceID,选择手动输入密码
     */
    HuangwwAuthIDStateInputPassword = 4,
    /**
     *  TouchID/FaceID 被系统取消 (如遇到来电,锁屏,按了Home键等)
     */
    HuangwwAuthIDStateSystemCancel = 5,
    /**
     *  TouchID/FaceID 无法启动,因为用户没有设置密码
     */
    HuangwwAuthIDStatePasswordNotSet = 6,
    /**
     *  TouchID/FaceID 无法启动,因为用户没有设置TouchID/FaceID
     */
    HuangwwAuthIDStateTouchIDNotSet = 7,
    /**
     *  TouchID/FaceID 无效
     */
    HuangwwAuthIDStateTouchIDNotAvailable = 8,
    /**
     *  TouchID/FaceID 被锁定(连续多次验证TouchID/FaceID失败,系统需要用户手动输入密码)
     */
    HuangwwAuthIDStateTouchIDLockout = 9,
    /**
     *  当前软件被挂起并取消了授权 (如App进入了后台等)
     */
    HuangwwAuthIDStateAppCancel = 10,
    /**
     *  当前软件被挂起并取消了授权 (LAContext对象无效)
     */
    HuangwwAuthIDStateInvalidContext = 11,
    /**
     *  系统版本不支持TouchID/FaceID (必须高于iOS 8.0才能使用)
     */
    HuangwwAuthIDStateVersionNotSupport = 12
};

@interface HuangwwAuthID : LAContext

//typedef void (^HuangwwAuthIDStateBlock)(HuangwwAuthIDState state, NSError *_Nullable error);
typedef void(^TouchIdFallBackBlock)(void);
typedef void(^TouchIdResultBlock)(BOOL useable, BOOL success, NSError *_Nullable error);

/**
 * 启动TouchID/FaceID进行验证
 * @param describe TouchID/FaceID显示的描述
 * @param block 回调状态的block
 */
//+ (void)Huangww_showAuthIDWithDescribe:(NSString *_Nullable)describe block:(HuangwwAuthIDStateBlock)block;

+ (instancetype)sharedInstance;


/**
 指纹/Face ID认证

 @param title 提示
 @param falllBackTitle 右侧按钮名
 @param fallBackBlock 右侧按钮回调
 @param resultBlock 结果回调
 */
+ (void)showTouchIdWithTitle:(NSString *_Nullable)title falldBackTitle:(NSString *)falllBackTitle fallBackBlock:(TouchIdFallBackBlock)fallBackBlock resultBlock:(TouchIdResultBlock)resultBlock;

/**
 密码弹框

 @param title 提示
 @param resultBlock 结果
 */
+ (void)tryShowTouchIdOrPwdInterface:(NSString *)title resultBlock:(TouchIdResultBlock)resultBlock;


/**
 移除指纹或faceid保存信息
 */
+ (void)RemoveAuthID;


/**
 保存手势解锁
 */
+ (void)GestureOpen;


/**
 移除手势解锁
 */
+ (void)RemoveGesture;

+ (NSData *)currentRAuthID;

// 保存手势
+ (void)SaveGesturePassword:(NSString *)gesture;

// 获取手势
+ (NSString *)GetGesturePassword;
@end

NS_ASSUME_NONNULL_END
